﻿using Microsoft.AspNetCore.SignalR;
using PLCS.Application.EquipmentApp.Hubs;
using PLCS.Domain.Logs;
using PLCS.Domain.Shared.Enums;

namespace PLCS.Web.EventHandlers;

public class ErrorLogCountChangedEventHandler : ILocalEventHandler<ErrorLogCountChangedEvent>, ITransientDependency
{
    private readonly IHubContext<FrameHub> _hubcontext;

    public ErrorLogCountChangedEventHandler(IHubContext<FrameHub> hubcontext)
    {
        _hubcontext = hubcontext;
    }

    public async Task HandleEventAsync(ErrorLogCountChangedEvent eventData)
    {
        await _hubcontext.Clients.All.SendAsync("ChangeErrorLogCount", eventData.ErrorLogCount);
    }
}